<template>
    <div class="main">
        <div class="cmain">
            <el-select v-model="week" multiple placeholder="请选择哪几周上机">
                <el-option
                  v-for="item in options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
            </el-select>
            <el-cascader v-model="time" :props="props" :options="woptions" clearable placeholder="请选择具体的上机时间段" class="text1"></el-cascader>
            <el-cascader v-model="course" :options="coptions" clearable placeholder="请选择上机的课程信息" class="text2"></el-cascader>
            <el-button type="primary" round @click="add">添加</el-button>
        </div>
    </div>
</template>

<script>
export default {
  data () {
    return {
      options: [{
        value: '1',
        label: '第一周'
      }, {
        value: '2',
        label: '第二周'
      }, {
        value: '3',
        label: '第三周'
      }, {
        value: '4',
        label: '第四周'
      }, {
        value: '5',
        label: '第五周'
      }, {
        value: '6',
        label: '第六周'
      }, {
        value: '7',
        label: '第七周'
      }, {
        value: '8',
        label: '第八周'
      }, {
        value: '9',
        label: '第九周'
      }, {
        value: '10',
        label: '第十周'
      }, {
        value: '11',
        label: '第十一周'
      }, {
        value: '12',
        label: '第十二周'
      }, {
        value: '13',
        label: '第十三周'
      }, {
        value: '14',
        label: '第十四周'
      }, {
        value: '15',
        label: '第十五周'
      }, {
        value: '16',
        label: '第十六周'
      }, {
        value: '17',
        label: '第十七周'
      }, {
        value: '18',
        label: '第十八周'
      }, {
        value: '19',
        label: '第十九周'
      }, {
        value: '20',
        label: '第二十周'
      }],
      woptions: [
        {
          value: '1',
          label: '周一',
          children: [{
            value: '1',
            label: '1-2'
          }, {
            value: '2',
            label: '3-4'
          }, {
            value: '3',
            label: '5-6'
          }, {
            value: '4',
            label: '7-8'
          }, {
            value: '5',
            label: '9-10'
          }]
        },
        {
          value: '2',
          label: '周二',
          children: [{
            value: '1',
            label: '1-2'
          }, {
            value: '2',
            label: '3-4'
          }, {
            value: '3',
            label: '5-6'
          }, {
            value: '4',
            label: '7-8'
          }, {
            value: '5',
            label: '9-10'
          }]
        },
        {
          value: '3',
          label: '周三',
          children: [{
            value: '1',
            label: '1-2'
          }, {
            value: '2',
            label: '3-4'
          }, {
            value: '3',
            label: '5-6'
          }, {
            value: '4',
            label: '7-8'
          }, {
            value: '5',
            label: '9-10'
          }]
        },
        {
          value: '4',
          label: '周四',
          children: [{
            value: '1',
            label: '1-2'
          }, {
            value: '2',
            label: '3-4'
          }, {
            value: '3',
            label: '5-6'
          }, {
            value: '4',
            label: '7-8'
          }, {
            value: '5',
            label: '9-10'
          }]
        },
        {
          value: '5',
          label: '周五',
          children: [{
            value: '1',
            label: '1-2'
          }, {
            value: '2',
            label: '3-4'
          }, {
            value: '3',
            label: '5-6'
          }, {
            value: '4',
            label: '7-8'
          }, {
            value: '5',
            label: '9-10'
          }]
        },
        {
          value: '6',
          label: '周六',
          children: [{
            value: '1',
            label: '1-2'
          }, {
            value: '2',
            label: '3-4'
          }, {
            value: '3',
            label: '5-6'
          }, {
            value: '4',
            label: '7-8'
          }, {
            value: '5',
            label: '9-10'
          }]
        },
        {
          value: '7',
          label: '周日',
          children: [{
            value: '1',
            label: '1-2'
          }, {
            value: '2',
            label: '3-4'
          }, {
            value: '3',
            label: '5-6'
          }, {
            value: '4',
            label: '7-8'
          }, {
            value: '5',
            label: '9-10'
          }]
        }
      ],
      coptions: [
        {
          value: 'Web基础',
          label: 'Web基础',
          children: [{
            value: '于艳丽',
            label: '于艳丽'
          }]
        }
      ],
      props: { multiple: true },
      week: [],
      time: [],
      course: []
    }
  },
  methods: {
    async add () {
      this.$http.defaults.headers.post['Content-Type'] = 'application/json'
      await this.$http.post('/course/addCourse', {
        week: this.week,
        time: this.time,
        course: this.course
      }).then(res => {
        console.log(res)
        if (res.status === 200) return this.$message.success('课程添加成功~~')
        if (res.status !== 200) return this.$message.error('课程添加失败~~')
      }, err => {
        console.log(err)
      })
    }
  }
}
</script>

<style lang="less" scoped>
.main{
  position: fixed;
  top: 20%;
  left: 55%;
  transform: translate(-50%,0);
  height: 45%;
  width: 60%;
  background-color: #B3C0D1;
  box-shadow: 0 0 5px 10px  #D3DCE6;
  border-radius: 1%;
}
.cmain{
  position: absolute;
  height: 60%;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
}
.el-select{
  width: 100%;
  top: 0;
  background-color:  #B3C0D1;
}
.text1{
  top: 10%;
}
.text2{
  top: 20%;
}
.el-button{
  position: absolute;
  top: 85%;
  left: 0%;
  width: 100%;
}
.el-cascader{
  width: 100%;
}
.span{
  font-size: 15px;
}
</style>
